<template>
    <div class="latiao">
        <zujian3 @jszjg="getName4" v-for="(item, index) in ee" :key="index" :info="item"></zujian3>
        <div class="la-one-rr" @click="qq = true">支付({{ tt }})</div>
        <div class="la-two" v-if="qq" @click="getName5()">
            <div class="la-two-qq">总价格:{{ tt }}</div>
        </div>

    </div>
</template>

<script>
import zujian3 from "../components/djl/zujian3.vue"
export default {
    name: "",
    /*1. Vue扩展 */
    extends: "", // extends和mixins都扩展逻辑，需要重点放前面
    mixins: [],
    components: { zujian3, },
    /* 2. Vue数据 */
    props: {},
    model: { prop: "", event: "" }, // model 会使用到 props
    data() {
        return {
            qq: false,
            ee: [],
            tt: 0,
        };
    },
    computed: {},
    watch: {}, // watch 监控的是 props 和 data，有必要时监控computed
    /* 3. Vue资源 */
    filters: {},
    directives: {},
    /* 4. Vue生命周期 */
    created() {
        const ww = this.getShopList()
        this.ee = ww.result

    },
    mounted() { },
    destroy() { },

    /* 5. Vue方法 */
    methods: {
        getShopList() {
            const data = {
                result: [
                    {
                        name: "苹果",
                        price: 10,
                        status: 0
                    },
                    {
                        name: "栗子",
                        price: 20,
                        status: 0
                    },
                    {
                        name: "香蕉",
                        price: 30,
                        status: 0
                    },
                    {
                        name: "菠萝",
                        price: 40,
                        status: 0
                    },
                    {
                        name: "西红柿",
                        price: 5,
                        status: 0
                    },
                ],
            };
            return data
        },
        getName4() {
            this.tt = 0
            this.ee.forEach((item, index) => {
                this.tt = this.tt + item.price * item.status
            })
        },
        getName5() {
            const qw = this.getShopList()
            this.ee = qw.result
            this.getName4()
            this.qq = false
        }
    }
};
</script>


<style scoped lang="scss">
.latiao {
    width: 100%;
    height: 100vh;
    border: 1px solid red;



    .la-one-rr {
        height: 40px;
        border: 1px solid red;
        border-radius: 10px;
        background-color: blue;
        font-size: 17px;
        font-weight: 600;
        color: aliceblue;
        text-align: center;
        line-height: 40px;
        position: fixed;
        bottom: 0;
        right: 15px;
        left: 15px;


    }

    .la-two {
        bottom: 0;
        top: 0;
        left: 0;
        right: 0;
        position: fixed;
        background-color: rgba(0, 0, 0, 0.2);
        justify-content: center;
        align-items: center;
        display: flex;

        .la-two-qq {
            line-height: 60px;
            height: 60px;
            width: 300px;
            text-align: center;
            font-size: 24px;
            font-weight: 600;
            color: red;
            background-color: white;
            border-radius: 10px;
        }
    }
}
</style>